package com.basic.bio.chat.groupchat;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description:
 * @Date: 2024-03-28 19:03
 * @Author: wz
 **/
public class Server {

   public static List<Socket> socketList = new ArrayList<>();
    public static void main(String[] args) {
        try {
            ServerSocket ss = new ServerSocket(8888);
            while (true){
                Socket socket = ss.accept();
                System.out.println("客户端连接成功");
                socketList.add(socket);
                //服务端先接受消息，再分发给其它客户端
                new ServerSendThread(socket).start();
                new ServerReceiveThread(socket).start();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
